<extend name="Index/index"/>

<block name="box">
    <div class="view-product">
        <div class="info-center">
            <div class="manage-head">
                <h6 class="padding-left manage-head-con">{{$title}}</h6>
            </div>
        </div>
        <div class="layui-container" style="margin-top: 20px">
            <div class="layui-row">

                <div class="layui-col-md5 layui-col-md-offset1">
                    <form class="layui-form" action="{{:U('Goods/insert')}}" method="post" enctype="multipart/form-data" id="myform">
                        <!--商品名称-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" required  lay-verify="required"  autocomplete="off" class="layui-input" placeholder="请输入商品名称">
                            </div>
                        </div>
                        <!--商品分类-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品分类</label>
                            <div class="layui-input-block">
                                <select name="cate" lay-verify="required">
                                    <option value="" class="text-left"></option>
                                    <foreach name="catelist" item="value">
                                        <option value="{{$value.id}}"> {{:str_repeat("----",substr_count($value['path'],","))}}>{{$value.name}}
                                        </option>
                                    </foreach>

                                </select>
                            </div>
                        </div>
                        <!--商品类别-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品类别</label>
                            <div class="layui-input-block">
                                <input type="radio" name="goods_type" value="0" title="普通商品"checked>
                                <input type="radio" name="goods_type" value="1" title="秒杀商品" >
                                <input type="radio" name="goods_type" value="2" title="团购商品" >

                            </div>
                        </div>
                        <!--商品价格-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品价格</label>
                            <div class="layui-input-block">
                                <input type="number" name="price" required  lay-verify="required"  autocomplete="off" class="layui-input" placeholder="请输入商品价格" id="price">
                            </div>
                        </div>
                        <!--商品图片-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品图片</label>
                            <div class="layui-input-block">
                                <input type="file" name="photo" required  lay-verify="required"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <!--商品介绍-->
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">商品介绍</label>
                            <div class="layui-input-block">
                                <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit >立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form;

            //监听提交
            form.on('submit(formDemo)', function(data){
                layer.msg(JSON.stringify(data.field));
                return false;
            });
        });

        //如果价格小于等于0 时,就不能提交
        $(function(){
            $("#myform").submit(function(){
                if($("#price").val() <= 0){
                    alert("价格不能小于等于0");
                    return false;
                }else{
                    return true;
                }

            })
        })

    </script>
</block>